package com.example.myapplication.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.activity.EdgeToEdge;

import com.example.myapplication.R;
import com.example.myapplication.bases.BaseActivity;

public class MainActivity2 extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main2);

        Button bt2=findViewById(R.id.bt2);
        bt2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //以下虽然可以回到原来的页面，但是会在栈里不断创造一个Intent，使用方法2解决
//                方法1：
//                Intent intent=new Intent();
//                intent.setClass(MainActivity2.this, MainActivity.class);
//                startActivity(intent);
//                方法2:
                MainActivity2.this.finish();
            }
        });
        Button bt_toSaveStateActivity=findViewById(R.id.bt_toSaveStateActivity);
        bt_toSaveStateActivity.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent();
                intent.setClass(MainActivity2.this, SaveStateActivity.class);
                startActivity(intent);
            }
        });
    }
}